package com.example.myapplication;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.R;
import com.example.myapplication.util.ActivityStack;

public abstract class BaseActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityStack.INSTANCE.pushIn(this);
        getSupportActionBar().hide();
        setContentView(getLayoutId());

        View view = findViewById(R.id.btBack);


        if (null!=view){
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
        }

        initView();
        setListener();
        logicStart();
    }

    public void refreshState(Bundle Bundle){

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityStack.INSTANCE.popOut(this,false);
    }

    protected abstract void logicStart();

    protected abstract void initView();

    public abstract int getLayoutId();

    protected void setListener(){

    }
}
